package com.android.lovingpet.common;

import android.os.Bundle;
import android.util.Log;

import com.android.lovingpet.util.HttpUtil;
import com.android.lovingpet.util.MyHttp;
import com.android.lovingpet.util.URLStore;
import com.android.lovingpet.util.Utility;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/**
 * Created by ikata on 2018/4/13.
 */

public class Model {

    public static void uploadVideo1(HashMap params, File file, Back back)
    {
        HashMap<String,File> files=new HashMap<>();
        files.put("video",file);
        MyHttp.getInstance().postAsync(Utility.getJSessionId(),URLStore.VIDEO_UPLOAD, params, files, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                back.onFailure(MyHttp.getFailureMeg());
            }
            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String responseData=response.body().string();
                Log.d("uploadVideo",responseData);
                int code= HttpUtil.getCode(responseData);
                Bundle bundle=new Bundle();
                bundle.putInt("code",code);
                back.onSuccess(bundle);
            }
        });
    }
}
